/**
 * 
 */
package com.eagle.coders.security.transaction.beans;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;


@Embeddable
public class UserLimitPK implements Serializable{
    
	private static final long serialVersionUID = 1L;

	private Integer userId;
    
    private String moduleCode;
    
    private String currencyCode;
    
    public UserLimitPK(){
    }
    
    public UserLimitPK(Integer userId, String moduleCode, String currencyCode){
        this.userId = userId;
        this.moduleCode = moduleCode;
        this.currencyCode = currencyCode;
    }
    
    @Column(name="FCCD", nullable = false)
    public String getCurrencyCode() {
        return currencyCode;
    }

    public void setCurrencyCode(String currencyCode) {
        this.currencyCode = currencyCode;
    }
    
    @Column(name="MOD_CD", nullable = false)
    public String getModuleCode() {
        return moduleCode;
    }

    public void setModuleCode(String moduleCode) {
        this.moduleCode = moduleCode;
    }
    
    @Column(name="USR_ID")
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    
    @Override
    public boolean equals(Object other){
        boolean areEqual = false;
        
        if(other instanceof UserLimitPK){
            UserLimitPK otherUserLimitPK = (UserLimitPK)other;
            
            areEqual = (otherUserLimitPK.userId.equals(userId) && 
                        otherUserLimitPK.currencyCode.equals(currencyCode)&&
                        otherUserLimitPK.moduleCode.equals(moduleCode));
        }
        return areEqual;
    }

    @Override
    public int hashCode() {
        int hashcode = 31 * (this.userId.hashCode() + this.currencyCode.hashCode() +
                        this.moduleCode.hashCode()); 
        return hashcode;
    }
}
